{include file="public/header" /}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('admin/Activity/show')}">返回</a></li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                    <form class="layui-form form-container" action="{:url('admin/Activity/addm')}" method="post">




                        <div class="layui-form-item">
                        <label class="layui-form-label">活动商品名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="title" value="" required  lay-verify="required" placeholder="请输入商品名称" class="layui-input">
                        </div>
                    </div>





                        <div class="layui-form-item">
                            <label class="layui-form-label">活动商品详情</label>
                    <div class="layui-input-block">
                        <input type="text" name="content" value="" required  lay-verify="required" placeholder="请输入商品详情" class="layui-input">
                    </div>
                </div>






                        <div class="layui-form-item">
                        <label class="layui-form-label">商品分类ID</label>
                        <div class="layui-input-block">
                            <select name="goods_class_name" lay-verify="required">
                                {volist name="list" id="val"}
                                <option value="{$val.goods_class_name}">{$val.goods_class_name}</option>
                               {/volist}
                            </select>
                        </div>
                    </div>




                        <div class="layui-form-item">
                        <label class="layui-form-label">活动商品图片</label>
                        <div class="layui-input-block">
                            <span onclick="getElementById('inputfile').click()" class="layui-btn" style="color:#fff">添加活动图片</span>
                            <input type="file" multiple="multiple" id="inputfile" style="height:0;width:0;z-index: -1; position: absolute;left: 10px;top: 5px;"/>
                            <span class="loading"></span>
                        </div>
                    </div>


                        <div class="layui-form-item">
                        <label class="layui-form-label">商品状态</label>
                        <div class="layui-input-block">
                            <input type="radio" name="deleted" value="1" title="删除" checked="checked">
                            <input type="radio" name="deleted" value="2" title="保留">
                        </div>
                    </div>







                        <div class="layui-form-item">
                        <label class="layui-form-label">排序</label>
                        <div class="layui-input-block">
                            <input type="text" name="sort" value="1" required  lay-verify="required" class="layui-input">
                        </div>
                    </div>





                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="submit" class="layui-btn" value="保存数据">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{include file="public/footer" /}
<script>
    $(document).ready(function(){
        //响应文件添加成功事件

        $("#inputfile").change(function(){
            //创建FormData对象
            var data = new FormData();
            //为FormData对象添加数据
            $.each($('#inputfile')[0].files, function(i, file) {
                data.append('upload_file'+i, file);
            });
            $(".loading").show();	//显示加载图片
            //发送数据
            $.ajax({
                url:"{:url('Activity/uploads')}",
                type:'POST',
                data:data,
                cache: false,
                contentType: false,		//不可缺参数
                processData: false,		//不可缺参数
                success:function(result){
                    layer.open({
                        type: 1,
                        title:'<div style="color:orange;font-size: 23px;">添加图片成功(2秒过后自动关闭)</div>',
                        skin: 'layui-layer-demo', //样式类名
                        closeBtn: 0, //不显示关闭按钮
                        shift: 1,
                        area: ['500px', '300px'], //宽高
                        shadeClose: true, //开启遮罩关闭
                        time: 2000,
                        content:"<block id='feedback'>"+ result +"</block>"

                    });

                },
                error:function(){
                    alert('上传出错');
                    $(".loading").hide();	//加载失败移除加载图片
                }
            });
        });
    });
</script>